package com.xinzi.apartment.controller;

import com.xinzi.apartment.common.utils.PageUtils;
import com.xinzi.apartment.entity.BuildingInfoEntity;
import com.xinzi.apartment.service.BuildingInfoService;
import com.xinzi.apartment.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author xinzi
 * @email 1228604898@qq.com
 * @date 2021-10-04 17:16:18
 */
@RestController
@RequestMapping("apartment/buildinginfo")
public class BuildingInfoController {
    @Autowired
    private BuildingInfoService buildingInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("apartment:buildinginfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = buildingInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("apartment:buildinginfo:info")
    public R info(@PathVariable("id") Integer id){
		BuildingInfoEntity buildingInfo = buildingInfoService.getById(id);

        return R.ok().put("buildingInfo", buildingInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("apartment:buildinginfo:save")
    public R save(@RequestBody BuildingInfoEntity buildingInfo){
		buildingInfoService.save(buildingInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("apartment:buildinginfo:update")
    public R update(@RequestBody BuildingInfoEntity buildingInfo){
		buildingInfoService.updateById(buildingInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("apartment:buildinginfo:delete")
    public R delete(@RequestBody Integer[] ids){
		buildingInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
